package com.ado.abyss.core.manager.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ado.abyss.core.dal.dao.SysRoleMapper;
import com.ado.abyss.core.dal.model.SysRole;
import com.ado.abyss.core.manager.SysRoleManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(value = "sysRoleManager")
public class SysRoleManagerImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleManager{

    @Autowired
    private SysRoleMapper sysRoleMapper ;


    @Override
    public SysRole findByName(String name) {
        return sysRoleMapper.findByName(name);
    }

    @Override
    @Transactional
    public boolean saveRole(SysRole record) {
        boolean flag = false ;
        int result = sysRoleMapper.insertSelective(record) ;
        if (result == 1) {
            flag = true ;
        }
        return flag;
    }

    @Override
    public SysRole findById(Long id) {
        return sysRoleMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional
    public boolean deleteByIds(List<Long> ids) {
        boolean flag = false ;
        int result = sysRoleMapper.deleteByIds(ids) ;
        if (result == 1) {
            flag = true ;
        }
        return flag;
    }
}
